None
The Raspberry Pi Foundation provides support for the use of Raspberry Pi Camera modules on various devices, including the Raspberry Pi 4B. Documentation can be found here.
High resolution images require additional gpu_mem. This can be set using the command line raspi-config under performance options.
# test for camera presence
import picamera
with picamera.PiCamera() as cam:
print(cam.revision)
imx477
Camera preview combined with a digital zoom features provides a useful means of acheiving critical focus. Documentation for PiCamera.zoom = (a, b, c, d), however, is sketchy. With a bit of experimentation, the parameters appear to represent
# preview image on screen -- focus camera
import picamera
import time
with picamera.PiCamera() as camera:
camera.start_preview()
time.sleep(1)
# zoom in effect
for k in range(0, 950):
camera.zoom = (k/2000, k/2000, (1000-k)/1000, (1000-k)/1000)
time.sleep(0.01)
time.sleep(20)
# capturing images to files
import picamera
import time
N = 5
with picamera.PiCamera() as camera:
camera.start_preview()
time.sleep(2)
tic = time.time()
for k in range(0, N):
camera.resolution = (4056, 3040)
camera.capture(f"test{k}.jpg")
toc = time.time()
print(f"fps = {(toc-tic)/N}")
fps = 1.6322479248046875
# capture high resolution image to a stream
from io import BytesIO
import picamera
import time
import PIL.Image
# capture image to stream
stream = BytesIO()
with picamera.PiCamera() as camera:
camera.resolution = (4056, 3040)
camera.start_preview()
time.sleep(2)
camera.capture(stream, format="jpeg")
# rewind stream
stream.seek(0)
# display image
with PIL.Image.open(stream) as im:
display(im)